import { type RouteConfig, index, route } from "@react-router/dev/routes";

// 定义路由配置，包含名称信息
const routes = [
  { type: "index", component: "routes/home.tsx", name: "首页" },
  {
    type: "route",
    path: "/login",
    component: "routes/login.tsx",
    name: "登录页",
  },
  {
    type: "route",
    path: "/contant",
    component: "routes/contant.tsx",
    name: "联系我们",
  },
  {
    type: "route",
    path: "/index",
    component: "routes/index.tsx",
    name: "索引页",
  },
  {
    type: "route",
    path: "/table",
    component: "routes/table.tsx",
    name: "表格页",
  },
  {
    type: "route",
    path: "/tableForm",
    component: "routes/tableForm.tsx",
    name: "表格表单",
  },
  {
    type: "route",
    path: "/interactive",
    component: "routes/interactive.tsx",
    name: "组件交互",
  },
  {
    type: "route",
    path: "/hooks",
    component: "routes/hooks.tsx",
    name: "hook页面",
  },
  {
    type: "route",
    path: "/redux",
    component: "routes/redux.tsx",
    name: "redux页面",
  },
  {
    type: "route",
    path: "/map",
    component: "routes/map.tsx",
    name: "地图页面",
  },
];

// 转换为 React Router 格式
export default routes.map((routeConfig) => {
  if (routeConfig.type === "index") {
    return index(routeConfig.component);
  } else {
    return route(routeConfig.path, routeConfig.component);
  }
}) satisfies RouteConfig;

// 导出路由配置供其他组件使用
export { routes as routesConfig };
